Add cleanup and fix postgres integer/serial problem