Refactored classes to better utilise inheritance

The code used some unnecessary workarounds, as PHP has built-in mechanisms to handle these cases. The individual commits contain more information.