Fix and refactor methods in database class. Add sites addition with unique code

Fixes #14