Code review and small fixes