ML: Cleaned main, removed excess functions from db