Solved #4 and minor changes