Fixed bug in update loop.