Added support to operate on methods and cleaned code