added second init parameter
fixed some bugs