Fix pep8 and PyDev warnings
Rearange methods to facilitate profiling