Cleaned up
Fixed a bug
Fixed typo
Added a missing namespace declaration
Got rid of the ?: operator, which was unsafe to use at this place