Removed $class and replaced it with the standard constructor key. Also
had to modifiy some stuff to make constructor works correctly.