Fixed Notices and PHP errors