changes in files organization

Did some changes in files organization. I have edited the code and moved
the appropriate functions to the respective files