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

Fixes #14 
Ahh, I thought `unless` ran until the check passed. Great to know that :)