Fixes some bugs that gives unnecessary warnings

Arrays in javascript are a misleading things must use length to check if they exist or not.

Also fixes uo some indentations