a few small fixes to allow this to work on mysql