Fixed leaks;
Some improvements in sensor reading