Fixed problem with storing enumerations. Related to ticket:3889. Also committed some minor performance improvements for result storing.