Tidy up, bug fixing