Bug fixes and finished adding database