Extensive changes to documentation and demos; updates to main functions