Move some surface functions into source file