fix rectangle_sum() near corners; fix memory allocation; some keyboard control; tweaks.