Added JavaDoc and fixed some minor bugs discovered while testing
Added JavaDoc