fixed some errors and typos, added more detailed comments. final submission