Made the code somewhat niceier.