Added comments, exception and code tweaks