Somehow works. Needs cleanup.