reordered some functions, removed a useless function