Minor fixes

Made it more generic, tidied areas up.