Fixed memory leak + added block handler