More code cleanup and stuff

Signed-off-by: Peter Mårtensson <veritas.is.me@gmail.com>