Comments added, bugs fixed