Fixed ambiguous naming, moved code around for consistency