Refined querying from database, API structure.

Not working, though needs more debugging.
Merge branch 'master' of https://github.com/MercuryGroup/BISystem