Add postgres support, clean code, code review