Refactored inner classes and fixed tab problem from previous commits