codereview & cleanup