Cleaning some functions and adapting to github