moved event value encoding stuff to a separate class