Update Makefile.am
Fix formatting according to PEP8
Remove redundant code.
Rearrange functions for better formatting
Fix formatting according to PEP8