Refactor + fix for issue where blank line was coming through to compiled document