Fixed DB issues & begun to add API layer