Add debug log and varius codestyle improvements