Fixed errors to work with older PHP versions