Code cleanup / refactor