Some more refactorization.
Starting to look somewhat good.