Refactored database and restored basic functionality. #37