Finished stable implementation (as far as tested), still requires more testing.