From team7. Fixing a few issues that static analyzer caught and adding a few rules to makefile.