Tidied up code.

  - Consistent array style (square brackets)
  - Always uses braces on conditions
  - Removed some dead code.