added all functionality. Need to track down possible bugs.