code cleanup, introduced greed mode for functions