Refactor some things

Signed-off-by: Sam Phippen <samphippen@googlemail.com>