Extract class runtime functions into own file

See #1007