Bucket fill algorithm now works properly and faster but uses more memory