Added some metamethods for more flexible API.