Updated with some TODOs, also added some db functions