Numerous bug fixs and feature additions