Cleaned up a bit from tutorial code