Moving time methods to utils
Removing unused imports
Refactoring to allow extensions for middleware
Python-way type comparison