Moved functions into separate file.