fixed bugs and warnings