Fixed bug in reporting parse error on optional arument
Refactored functions for applying methods to arguments