Cleaned up code and imports a bit