http state machine cleanup, db interface improved