switch to non member non friend

Remove stuff that c++11 enum class provides by default. Switch other
functions to be non member non friends.