Remove prepare_entry function, tidy up