Commit Briefs
Code cleanup + documentation
1. some macros were rewritten as proper functions 2. various comment were added to explain functions parameters and return values 3. the input handling were rewritten and refactored. Now a single function will choose the action to perform, so no more code duplication!