Fix a number of unsafe operations (mostly forced unwrapping)

Swift is nice. I just searched for exclamation marks and made the program safer almost mechanically.
:arrow_up: This man has a point.