Completed both problems

Also checked for bugs, etc.