Refactored server

Mostly GETs and DB access