Some code cleanup and PEP validation and bugfixes

Signed-off-by: Thomas Spycher <tspycher@zerodine.com>