Fixed numerous bugs; more remain