Fixed warnings and a couple bugs