Adding getUrlPart helper function and tidying up/bug fixes