Fix for trying to call a method on Element class when it's no longer in use. Also convert one function to use threading macro, and cleanup indent and whitespace.