Code cleanup

I split #182 into two parts, this one is for "real" changes while #182 is for syntactic stuff that will break merges