Fixed bugs and added safety code
Merge branch 'master' of https://github.com/Bindernews/FRC-4611