fixed some issues after codereview