Review

Just did a very quick semi-automated code review that revealed these few problems.
Hope it's cool with you.