Resolved #2 and made some minor fixes