Fix bugs. Refactor.