fixed some issues, needs review