massive refactoring. server db caching implemented. in server2.py.