Finished refactoring and static analysis