Remove some unused code and update database structure