Bugs and warnings fixed.