Complete remake due to changes from source. Testing.