Add corner defense code

Signed-off-by: Kiril Nesenko <nesenko@gmail.com>