use max_usage=True in %memit (less memory consumption)

Also some refactoring