refactored DB structure. check temp directory for details