Re-implemented code tidy removing unnecessary empty() calls