Implemented default function's parameters values.

... and also fixed one bug and cleaned up some parts of code.