Small optimisation with list operations

Also removed some code duplication / cleared up some code.