Removed local functions, seems to drop code size by quite a bit.