Reorganized functions into separate files