Adds a few little refactorings / corrections