code cleanup & sorting