Refactored code using some boolean convenience functions to improve code...

... readability.

I'll add a second patch containing only reformatting once this patch has been accepted, to clean up the formatting problems encountered on the previous patch.
Okay - but PMD warns on

```
if(bool){
  if(bool){
  } // no else
}
```