Code tidy-up and cleaner API