Fixed bug when assigning another type to method argument. Reorganized some code.