Better code analysis of methods to see when they are empty

Fixes #492
Added a guard in the main method + spec