Added TYPE constants
Fixed two more bugs