Major bug fixes. Image handling yet to be done.