Implemented suggestions/fixes by @keflavich