Remove old mock functions
Some refactoring and PEP8 fixes