Fix for backwashing problem and code readability improvements