Adding some extension methods

http://stackoverflow.com/q/14890435/634824