Fixed current browser compatibility and cleaned code