Forked from vidkun, slight tidy