Implements scale9

Scale 9 now works under all circumstances. Cleans up the implementation.