Refactoring, bugs & leaks