Fixed rege, also some code janitoring.

Signed-off-by: Anton Landberg <git@atnon.se>