Various bug fixes for notices on PHP5