Fixed bug and warnings