Added changes by Alex Bukach.