added some exceptions and bitmap handling