Code formatted, renamed several functions