fixed some little bugs & added debug mode