A bunch more warnings corrections, some small possible bugs fixed too