Add bitplane support, fix numerous bugs