add indexes and fix schema
fix a plethora of bugs