Added bugs, improvements and additional checks