re-factor database loading, javadocs