Fixed annoying PHP Notices

Prevent the array accesses to undefined positions