Code refactoring and remove of code with no effect

Some code refactoring. Replaced parts code with Emacs Lisp macros, depending on the purpose of code, to a more functional way of programming. 
Removed some unused code (lines of code with no effect).
No change in functionality.