move strmdup to common, fix some style here and there