Minor improvements (refactoring, debugging options)