Refactoring and fuck up fixes.