closes #52 + some fixes