more bug fixes

found while testing with erpal