Prototype pattern and bug fix