added log for rewrite
made file kindof more pep8-style
documented database.py