Small bug fixes
Merged with Phalanxia's branch.