Added namespace, proper composer autoloading, fixed code style, fixed typos, fixed php errors (undefined variable etc)