cleanup, more functions ported