Some rewrite on orm and scheduler, needs testing