Minor edits and optimizations
Added legacy syntax support. A little hackey but works.