typecheck: Handle collection-record
typecheck: fix some compile errors