first implementation working to spec (except for full int64 support)