Improved w/minor corrections and suggestions from carlosdcastillo