Refactor more

Signed-off-by: Heikki Salo <heikki.ao.salo@iki.fi>