Removed hard-coded parameters, now get them from arguments; added some documentation