Cleaned up implementation of #48. We have proper java objects instead of ad-hoc HashMaps.