Removed class casts that were removed in the 5.1 to 5.2 dev process,
pulled in an additional logical condition as well
added in a deprecated method missing from 5.2, also minor formatting