Fixed bug in is_square, moved pool declaration to reduce memory issues