big refactory and start moving to postgres