fixed missing table bug and minor cleanups