Remove unused code and clean up files and database