Minor code tweaks, this needs a lot of forethought