Huge code clean up