Tidy up of prefix assignment code

-Improved names and refactored a little