Function wrapping and constant fixes