Some refactoring. Last commit before issue tracking.