Code refactor + clean up