Moving scale functions to own file.
Some reorgination.