Fix database implentation & add auth system