Bugfix. NOT TESTED. TESTS OUT OF DATE.