Changed file structure and added compatibility with php 5.3