fixed permissions when creating db by using os.expanduser
added more stats