Made minor changes, and added some code for blocks (not finished, don't debug yet).