Bug fixes(hopefully) and added API