Miscellaneous fixes for potential PHP notices